import Vue from "vue"
import Vuex from "vuex"
import we from './we'
// import getters from "./getters/getters"
// import sysuser from "./modules/sysuser"

Vue.use(Vuex)
const store = new Vuex.Store({

    state: {
        // 存储token
        Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : '',
        //存储用户id
        Uid:localStorage.getItem('Uid') ?localStorage.getItem('Uid') : '',
        UserMessage:localStorage.getItem('UserMessage') ? localStorage.getItem('UserMessage') :{
            uName:'',
            email:''
        }
    },
    modules:{
        we,
    },
    mutations: {
        // 修改token，并将token存入localStorage
        changeLogin (state, user) {
            state.Authorization = user.Authorization;

            localStorage.setItem('Authorization', user.Authorization);
            console.log(user.Authorization)
        },
        changUid(state,user) {
            state.Uid = user.Uid;
            localStorage.setItem('Uid',user.Uid);
        },
        saveUMessage(state,user){
            console.log(user)
            
            state.UserMessage=user
            console.log(user)
            localStorage.setItem('UserMessage',JSON.stringify(user));
            console.log(localStorage.getItem('UserMessage'))
        }
    }
});

export default store